package com.jt.controller;

import com.jt.pojo.Item;

import com.jt.vo.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import com.jt.service.ItemService;

@Controller
@RequestMapping("/item")
public class ItemController {
	
	@Autowired
	private ItemService itemService;

	@GetMapping("/query")
	@ResponseBody
	public Object getAllItem(Integer page, Integer rows){
		return itemService.getAllItem(page,rows);

	}

	@PostMapping("/update")
	@ResponseBody
	public JsonResult updateItemById(Item item){
		return new JsonResult(itemService.updateItemById(item));
	}

	@PostMapping("/save")
	@ResponseBody
	public JsonResult saveItem(Item item, String itemDesc){
		return new JsonResult(itemService.saveItem(item,itemDesc));
	}

	@PostMapping("/delete")
	@ResponseBody
	public JsonResult deleteItem(Long... ids){
		return new JsonResult(itemService.deleteItemByIds(ids));
	}

	@PostMapping("/updateStatus/{status}")
	@ResponseBody
	public JsonResult updateStatus(@PathVariable Integer status, Long...ids){
		return new JsonResult(itemService.updateStatus(status,ids));
	}





}
